<template>
  <div>
    <el-menu
      :default-active="activeIndex2"
      class="el-menu-demo"
      mode="horizontal"
      @select="handleSelect"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b">

      <el-menu-item style="width:220px">酒店后台管理 </el-menu-item>
      <el-menu-item><router-link to="/admin">首页</router-link></el-menu-item>
      <el-menu-item style="float:right" @click="exit_btn">退出登录</el-menu-item>
      <el-submenu index="4" style="float:right">
        <!-- <template slot="title">{{$store.state.userInfo.name}}</template> -->
        <template slot="title">admin</template>
      </el-submenu>
    </el-menu>
  </div>
</template>

<script>
  export default{
    data(){
      return{
        activeIndex2:'0'
      }
    },methods:{
      handleSelect:function(){

      },
      exit_btn:function(){
        var that=this;
        this.$confirm('确定退出登录吗?', '提示', {
                  confirmButtonText: '确定',
                  cancelButtonText: '取消',
                  type: 'warning'
                }).then(() => {
                  that.$axios.post('/admin.php/login/exit_btn',this.$qs.stringify({name:'exit'})).then(
                    (res)=>{
                      if(res.data.code==1){
                         that.$message({
                           type:'success',
                           message:'退出成功'
                         });
                         setTimeout(function(){that.$router.push({'path':'/login'})},1300);
                      }else{
                        that.$message.error(res.data.msg);
                      }
                    }
                  ).catch(
                    (res)=>{
                      that.$message.error('网络繁忙~');
                    }
                  )
                }).catch(() => {

                });
      }
    }
  }
</script>

<style>
</style>
